<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || eregi(".inc.php",$_SERVER['PHP_SELF'])) {
	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
	exit;
}


$box_content = new XTemplate ("skins/".$configSkin['value']."/styleTemplates/categories.tpl");


/* create nav categories */
$getTotalDBs = mysql_query("SELECT value FROM affiliSt_config WHERE name = 'totalDBs'");
$totalDBs = mysql_fetch_assoc($getTotalDBs);
$totalnavs = $totalDBs['value'];
$prevpieces = array();
for ($n=1;$n<=$totalnavs;$n++) {
$getNewNav = mysql_query("SELECT value FROM affiliSt_config WHERE name = 'nav$n'");
$newNav = mysql_fetch_assoc($getNewNav);
	if ($newNav['value'] != NULL) {
	$pieces = explode("-:-", $newNav['value']);
	$navarray = array_merge($prevpieces, $pieces);
	$prevpieces = $navarray;
	}
}
//$navarray = '';
if (is_array($navarray)) {
	sort($navarray);
	
	$total = count($navarray);
	$counter = 0;
	for ($i=0;$i<$total;$i++) {
	$spieces = explode("(:)", $navarray[$i]);
		if ($spieces[0] == $uniquepieces[$counter-1][0]) {
		$counter = $counter - 1;
		$uniquepieces[$counter] = array_unique(array_merge($spieces, $uniquepieces[$counter]));
		} else {
		$uniquepieces[$counter] = $spieces;
		}
	$counter++;
	//$prevspieces = $spieces;
	}
	
	$total = count($uniquepieces);
	for ($u=0;$u<$total;$u++) {
		if ($uniquepieces[$u][0] == ucwords(strtolower(str_replace("-", " ", $_GET['pc'])))) {
		$box_content->assign("FONTSTYLE",'catNavOn');
		} else {
		$box_content->assign("FONTSTYLE",'catNavOff');
		}
		if ($navOpt[7] == 1) {
		// html perma
		$box_content->assign("LINKDATA",$installDir['value'].'products/'.str_replace(" ", "-", $uniquepieces[$u][0]).'.html');
		} else {
		// php link
		$box_content->assign("LINKDATA",$installDir['value'].'index.php?case=products&pc='.str_replace(" ", "+", $uniquepieces[$u][0]));
		}
	$box_content->assign("DATA",$uniquepieces[$u][0]);
	$keepcat = $uniquepieces[$u][0];
	unset($uniquepieces[$u][0]);
	//sort($uniquepieces[$u]);
	
	//$uniquepieces[$u] = '';
		if (is_array($uniquepieces[$u])) {
		$stotal = count($uniquepieces[$u]);
			if ($stotal > 0) {
			shuffle($uniquepieces[$u]);
				if ($navOpt[14] == 1) {
					if ($stotal < 6) {
					$totalsublinks = $stotal;
					} else {
					$totalsublinks = 6;
					}
							
					if($stotal > 1) {
					$box_content->assign("OPENUL","<span>");
					$box_content->parse("categories.li.openul");
						for ($sl=0; $sl<$totalsublinks; $sl++) {
						$box_content->assign("SUBFONTSTYLE",'brandNavOff');
							if ($navOpt[7] == 1) {
							// html perma
							$box_content->assign("SUBLINKDATA",$installDir['value'].'subproducts/'.str_replace(" ", "-", $keepcat).'/'.str_replace(" ", "-", $uniquepieces[$u][$sl]).'.html');
							} else {
							// php link
							$box_content->assign("SUBLINKDATA",$installDir['value'].'index.php?case=subproducts&pc='.str_replace(" ", "+", $keepcat).'&pb='.str_replace(" ", "+", $uniquepieces[$u][$sl]));
							}
						$box_content->assign("SUBDATA",$uniquepieces[$u][$sl]);
							if ($sl != $totalsublinks-1) {
							$box_content->assign("COMMA",',&nbsp;');
							} else {
							$box_content->assign("COMMA",'...<br />');
							$box_content->assign("CLOSEUL","</span>");
							$box_content->parse("categories.li.closeul");
							}
						$box_content->parse("categories.li.subli");
						}
					}
				}
			}
		$box_content->parse("categories.li");
		}
	}
// end if is_array	
}
			
$box_content->assign("TITLE","Products");
$box_content->assign("SKIN",$configSkin['value']);
$box_content->parse("categories");
$box_content = $box_content->text("categories");
?>